package com.bhkj.pdjhforotherapp.core.main.handler;

import android.Manifest;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.graphics.Color;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.bhkj.pdjhforotherapp.R;
import com.bhkj.pdjhforotherapp.common.Contact;
import com.bhkj.pdjhforotherapp.common.bean.JhResultBean;
import com.bhkj.pdjhforotherapp.common.bean.MainYwAllBean;
import com.bhkj.pdjhforotherapp.common.bean.QueueBusiness;
import com.bhkj.pdjhforotherapp.common.bean.SelectedItemBean;
import com.bhkj.pdjhforotherapp.common.callback.CallbackManager;
import com.bhkj.pdjhforotherapp.common.callback.IGlabolCallback;
import com.bhkj.pdjhforotherapp.common.parse.GsonProvider;
import com.bhkj.pdjhforotherapp.common.utils.NetIpUtils;
import com.bhkj.pdjhforotherapp.common.utils.Tools;
import com.bhkj.pdjhforotherapp.common.view.ShadowDrawable;
import com.bhkj.pdjhforotherapp.common.work.WorkHelper;
import com.bhkj.pdjhforotherapp.core.main.adapter.MainYwAdapter;
import com.bhkj.pdjhforotherapp.core.main.view.MainYwActivity;
import com.bhkj.pdjhforotherapp.core.main.viewmodel.MainYwViewModel;
import com.bhkj.pdjhforotherapp.core.printutilspjq.PrintManagerPjq;
import com.bhkj.pdjhforotherapp.core.readsfzprint.JHDetailActivity;
import com.blankj.utilcode.util.ActivityUtils;
import com.blankj.utilcode.util.CacheDiskStaticUtils;
import com.blankj.utilcode.util.GsonUtils;
import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.NetworkUtils;
import com.blankj.utilcode.util.ObjectUtils;
import com.blankj.utilcode.util.PermissionUtils;
import com.blankj.utilcode.util.SPUtils;
import com.blankj.utilcode.util.SizeUtils;
import com.blankj.utilcode.util.StringUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.google.gson.reflect.TypeToken;
import com.zhouyou.http.EasyHttp;
import com.zhouyou.http.callback.SimpleCallBack;
import com.zhouyou.http.exception.ApiException;

import net.lemonsoft.lemonhello.LemonHello;
import net.lemonsoft.lemonhello.LemonHelloAction;
import net.lemonsoft.lemonhello.LemonHelloInfo;
import net.lemonsoft.lemonhello.LemonHelloView;
import net.lemonsoft.lemonhello.interfaces.LemonHelloActionDelegate;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
import java.util.Timer;
import java.util.TimerTask;

import q.rorbin.badgeview.Badge;

public class MainYwHandler implements IMainYwHandlerContract, IMainYwHandlerContract.IMainAllYwCallback {
    private MainYwViewModel mainYwViewModel;
    private MainYwActivity mainYwActivity;
    private RecyclerView rv;
    private MainYwAdapter mainYwAdapter;
    private Badge mBadgeVehicleYw;
    private Badge mBadgeVehicleMan;
    private TextView mTvVehicleMan;
    private TextView mTvVehicleYw;
    private String mYwId;
    private static final String[] PERMISSIONS = new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE,Manifest.permission.READ_EXTERNAL_STORAGE};
    RequestOptions requestOptions = new RequestOptions()
            .fitCenter()
            .override(100, 100);

    public MainYwHandler() {
        mainYwViewModel = new MainYwViewModel(this);
        mainYwActivity = (MainYwActivity) ActivityUtils.getTopActivity();
        init();
    }

    private void init() {
        WorkHelper.launcherWorkWithCache();
        CacheDiskStaticUtils.put(Contact.PRINT_INIT_STATUS, "null");
        requestPermission();
        rv = mainYwActivity.getRecyclerView();
        mBadgeVehicleMan = mainYwActivity.getBadgeVehicleMan();
        mBadgeVehicleYw = mainYwActivity.getBadgeVehicleYw();
        mTvVehicleMan = mainYwActivity.getTvVehicleMan();
        mTvVehicleYw = mainYwActivity.getTvVehicleYw();
        initRecyclerView();
        getAllYw();

        clearPrint();
    }

    /**
     * 清除取号后无论是否取号成功所选中的数据
     */
    private void clearPrint() {
        CallbackManager.getInstance().addCallback(Contact.CLEAR_PRINT_DATA, o -> clear());
    }

    /**
     * 初始化RecyclerView
     */
    @SuppressLint("NewApi")
    private void initRecyclerView() {
        GridLayoutManager layoutManager = new GridLayoutManager(mainYwActivity, 4);
        rv.setLayoutManager(layoutManager);
        mainYwAdapter = new MainYwAdapter(R.layout.item_yw, null);
        rv.setAdapter(mainYwAdapter);
        mainYwAdapter.bindToRecyclerView(rv);
        updateYwForBatchLimit();
    }

    public MainYwAdapter getMainYwAdapter() {
        return mainYwAdapter;
    }

    @Override
    public void getAllYw() {
        mainYwAdapter.setNewData(null);
        mainYwViewModel.getAllYw();
    }

    /**
     * 处理机动车或者驾驶人业务
     *
     * @param b          true 选中机动车 false驾驶人
     * @param b2
     * @param jdcYwParam 保存业务类型key
     */
    @Override
    public void switchYwType(boolean b, boolean b2, String jdcYwParam) {
        if (b2) {
            if (mBadgeVehicleYw != null) {
                mBadgeVehicleYw.hide(b2);
            }
            if (mBadgeVehicleMan != null) {
                mBadgeVehicleMan.setBadgeText(StringUtils.getString(R.string.selected_title));
                mYwId = (String) mTvVehicleMan.getTag();
            }
        } else if (b) {
            if (mBadgeVehicleYw != null) {
                mBadgeVehicleYw.setBadgeText(StringUtils.getString(R.string.selected_title));
                mYwId = (String) mTvVehicleYw.getTag();
            }
            if (mBadgeVehicleMan != null) {
                mBadgeVehicleMan.hide(b);
            }
        }

        setButtonWithJBColor(b);
        mainYwAdapter.setNewData(getYwDataFromCache());
    }


    /**
     * 设置机动车业务和驾驶人业务按钮通过渐变色显示
     * 未选中渐变色[#da4453,#89216b]
     * 选中的渐变色[#636363,#a2ab58]
     */
    public void setButtonWithJBColor(boolean isVehicleYw) {
        if (isVehicleYw) {
            mTvVehicleYw.setSelected(true);
            mTvVehicleMan.setSelected(false);
        } else {
            mTvVehicleYw.setSelected(false);
            mTvVehicleMan.setSelected(true);
        }
        if (mTvVehicleYw.isSelected()) {
            showShadowTv(mTvVehicleMan, new String[]{"#636363", "#a2ab58", "#99636363"});
            showShadowTv(mTvVehicleYw, new String[]{"#da4453", "#89216b", "#99da4453"});
        } else {
            showShadowTv(mTvVehicleYw, new String[]{"#636363", "#a2ab58", "#99636363"});
            showShadowTv(mTvVehicleMan, new String[]{"#da4453", "#89216b", "#99da4453"});
        }

        if (mTvVehicleMan.isSelected()) {
            showShadowTv(mTvVehicleYw, new String[]{"#636363", "#a2ab58", "#99636363"});
            showShadowTv(mTvVehicleMan, new String[]{"#da4453", "#89216b", "#99da4453"});
        } else {
            showShadowTv(mTvVehicleMan, new String[]{"#636363", "#a2ab58", "#99636363"});
            showShadowTv(mTvVehicleYw, new String[]{"#da4453", "#89216b", "#99da4453"});
        }
    }

    /*
     * 显示带阴影的按钮
     * @param tv 控件
     * @param colors 针对于两个渐变色的情况，第三个是阴影的颜色
     */
    private void showShadowTv(TextView tv, String[] colors) {
        ShadowDrawable.setShadowDrawable(tv, new int[]{
                        Color.parseColor(colors[0]),
                        Color.parseColor(colors[1])},
                SizeUtils.dp2px(4),
                Color.parseColor(colors[2]),
                SizeUtils.dp2px(3),
                SizeUtils.dp2px(4), SizeUtils.dp2px(4));
    }

    @Override
    public void onAllYwSuccess(String res) {

        mainYwActivity.dismissLoading();
        MainYwAllBean ywAllBean = GsonProvider.getInstance().getGson().fromJson(res, MainYwAllBean.class);

        if (!ywAllBean.isSuccess()) {
            showTip("错误信息", ywAllBean.getMessage());
            return;
        }
        MainYwAllBean.Datas datas = ywAllBean.getDatas();
        if (ObjectUtils.isEmpty(datas)) {
            showTip("空信息", "暂无有效信息");
            return;
        }
        List<MainYwAllBean.Datas.Business> business = datas.getBusiness();
        if (ObjectUtils.isEmpty(business)) {
            showTip("空信息", "暂无有效业务信息");
            return;
        }
        MainYwAllBean.Datas.Dept dept = datas.getDept();
        if (ObjectUtils.isEmpty(dept)) {
            showTip("空信息", "部门信息为空");
            return;
        }


        if (ActivityUtils.isActivityAlive(mainYwActivity)) {
            Glide.with(mainYwActivity).applyDefaultRequestOptions(requestOptions)
                    .load(Contact.BASE_URL + ywAllBean.getDatas().getDept().getLogo()).into(mainYwActivity.getIvIcon());
        }

        
        mainYwActivity.getDeptName().setText(dept.getName());
        if ("1".equals(dept.getBatchflag())) {
            mainYwAdapter.setSelectedMax(Integer.parseInt(dept.getBatchmaxnum()));
        }
        int ywlxSize = business.size();

        for (int i = 0; i < ywlxSize; i++) {
            String ywName = business.get(i).getName();
            if (i == 0) {
                mYwId = business.get(i).getId();
                mTvVehicleYw.setText(ywName);
                mTvVehicleYw.setTag(business.get(i).getId());
                mainYwAdapter.setNewData(business.get(i).getVos());
            } else {
                if (ObjectUtils.isNotEmpty(business.get(i).getVos())) {
                    mTvVehicleMan.setVisibility(View.VISIBLE);
                    mTvVehicleMan.setText(ywName);
                    mTvVehicleMan.setTag(business.get(i).getId());
                }
            }
            CacheDiskStaticUtils.put(business.get(i).getId(), business.get(i));
        }

        CacheDiskStaticUtils.put(Contact.YW_ALL_LIST, GsonUtils.toJson(business));

    }

    /**
     * 在每天的晚上6点更新一下,获取最新的数据，主要是用来更新批量业务的限制的
     */
    private void updateYwForBatchLimit() {
        Timer timer = new Timer();
        TimerTask timerTask = new TimerTask() {
            @Override
            public void run() {
                getAllYw();
            }
        };

        timer.schedule(timerTask, strToDateLong("18:00:00"));
    }

    /**
     * string类型时间转换为date
     *
     * @param strDate
     * @return
     */
    public static Date strToDateLong(String strDate) {
        SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
        ParsePosition pos = new ParsePosition(0);
        Date strtodate = formatter.parse(strDate, pos);
        return strtodate;
    }

    /**
     * 从磁盘缓存中获取所有的业务信息
     *
     * @return List<MainYwAllBean.Datas.Business.Vos>
     */
    public List<MainYwAllBean.Datas.Business.Vos> getYwDataFromCache() {
        MainYwAllBean.Datas.Business business = (MainYwAllBean.Datas.Business) CacheDiskStaticUtils.getSerializable(mYwId);
        if (business == null) {
            return null;
        }
        return business.getVos();
    }

    /**
     * 跳转到业务确认页面
     * 确认
     */
    public void toJh(String jhType) {
        //判断是否有选中的业务
        //机动车业务就是一组

        String ywRes = CacheDiskStaticUtils.getString(Contact.SAVE_YW_SELECTED);
        if (ObjectUtils.isEmpty(ywRes)) {
            showTip(StringUtils.getString(R.string.empty_selected_tip));
            return;
        }
        String res = SPUtils.getInstance().getString(ywRes);
        if (ObjectUtils.isNotEmpty(res) && !res.equals("{}")) {
            toJhDetail(jhType);

//            ActivityUtils.startActivity(SelectedYwSureActivity.class);
//            mainYwActivity.overridePendingTransition(R.anim.left_to_right, R.anim.right_to_left);
        } else {
            showTip(StringUtils.getString(R.string.empty_selected_tip));
        }
    }

    @Override
    public void onAllYwError(ApiException e) {
        mainYwActivity.dismissLoading();
        showTip("访问服务器失败", "错误信息" + e.getMessage());
    }

    private void showTip(String title, String msg) {
        if (ActivityUtils.isActivityAlive(mainYwActivity)){
            LemonHello.getWarningHello(title, msg)
                    .addAction(new LemonHelloAction(StringUtils.getString(R.string.sure), (lemonHelloView, lemonHelloInfo, lemonHelloAction) -> {
                        lemonHelloView.hide();
                        getAllYw();
                    }))
                    .show(mainYwActivity);

        }
    }

    private void showTip(String tip) {
        if (ActivityUtils.isActivityAlive(mainYwActivity)){
            LemonHello.getErrorHello(tip, "")
                    .addAction(new LemonHelloAction(StringUtils.getString(R.string.sure), (lemonHelloView, lemonHelloInfo, lemonHelloAction) ->
                            lemonHelloView.hide())).show(mainYwActivity);
        }
    }

    private void requestPermission() {
        PermissionUtils.permission(PERMISSIONS)
                .request();
    }

    public void setBottomButtonColor(TextView pickNumTv, TextView clearAllTv, TextView vipTvPickup) {
        ShadowDrawable.setShadowDrawable(pickNumTv, new int[]{
                        Color.parseColor("#CE9FFC"), Color.parseColor("#7367F0")},
                SizeUtils.dp2px(6),
                Color.parseColor("#99CE9FFC"),
                SizeUtils.dp2px(6), SizeUtils.dp2px(5), SizeUtils.dp2px(2));
        ShadowDrawable.setShadowDrawable(clearAllTv, new int[]{
                        Color.parseColor("#FCCF31"), Color.parseColor("#F55555")},
                SizeUtils.dp2px(6),
                Color.parseColor("#99FCCF31"),
                SizeUtils.dp2px(6), SizeUtils.dp2px(5), SizeUtils.dp2px(2));

        ShadowDrawable.setShadowDrawable(vipTvPickup, new int[]{
                        Color.parseColor("#008000"), Color.parseColor("#006400")},
                SizeUtils.dp2px(6),
                Color.parseColor("#99008000"),
                SizeUtils.dp2px(6), SizeUtils.dp2px(5), SizeUtils.dp2px(2));
    }


    /**
     * 将选中的业务转换成json字符串传递到叫号详情页，刷完身份证将数据传递到服务中进行保存
     */
    private void toJhDetail(String qhType) {
        String businessStr = CacheDiskStaticUtils.getString(Contact.YW_ALL_LIST);
        List<MainYwAllBean.Datas.Business> businessArray = GsonUtils.fromJson(businessStr, new TypeToken<List<MainYwAllBean.Datas.Business>>() {
        }.getType());

        if (ObjectUtils.isEmpty(businessArray)) {
            clear();
            ToastUtils.showShort("数据丢失重新获取数据...");
            getAllYw();
            return;
        }

        List<SelectedItemBean> allSelectedItemBeans = getSelectedData(businessArray);
        List<QueueBusiness> queueBusinesses = new ArrayList<>();
        for (SelectedItemBean param : allSelectedItemBeans) {
            QueueBusiness queueBusiness = new QueueBusiness();
            queueBusiness.setBid(param.getId());
            queueBusiness.setBunum(param.getCount());
            queueBusiness.setName(param.getName());
            queueBusinesses.add(queueBusiness);
        }
        String queueBusinessJson = GsonProvider.getInstance().getGson().toJson(queueBusinesses);
//        saveSelectedYwToServer(queueBusinessJson, qhType, "0", "123456789012345678");

        if (mainYwActivity.getResources().getBoolean(R.bool.isQhj)) {
            Intent intent = new Intent(mainYwActivity, JHDetailActivity.class);
            intent.putExtra(Contact.SURE_YW, queueBusinessJson);
            intent.putExtra(Contact.QHTYPE, qhType);
            mainYwActivity.startActivity(intent);
        } else {
//            saveSelectedYwToServer(queueBusinessJson, qhType, "0", "123456789012345678");
            //TODO 测试保存业务接口
            if (Contact.PRINT_INIT_STATUS.equals(CacheDiskStaticUtils.getString(Contact.PRINT_INIT_STATUS))) {
                saveSelectedYwToServer(queueBusinessJson, qhType, "0", "123456789012345678");
            } else {
                PrintManagerPjq.getInstance().connectPrintDevice();
                ToastUtils.showShort(R.string.print_tatus_no);
            }
        }
    }

    /**
     * 初始化选中的业务
     *
     * @return 业务集合
     */
    private List<SelectedItemBean> getSelectedData(List<MainYwAllBean.Datas.Business> businessArray) {
        List<SelectedItemBean> allSelectedItemBeans = new ArrayList<>();
        //添加已选择的业务
        String res = SPUtils.getInstance().getString(CacheDiskStaticUtils.getString(Contact.SAVE_YW_SELECTED));
        HashMap<String, SelectedItemBean> selectedItemBeans = GsonProvider.getInstance().getGson().fromJson(res, new TypeToken<HashMap<String, SelectedItemBean>>() {
        }.getType());
        if (ObjectUtils.isNotEmpty(selectedItemBeans) && ObjectUtils.isNotEmpty(businessArray)) {
            final int size = businessArray.size();
            for (String key : selectedItemBeans.keySet()) {
                for (int i = 0; i < size; i++) {
                    if (businessArray.get(i).getId().equals(Objects.requireNonNull(selectedItemBeans.get(key)).getYwlxId())) {
                        SelectedItemBean selectedItemBean = selectedItemBeans.get(key);
                        selectedItemBean.setYwlxName(businessArray.get(i).getContent());
                        selectedItemBean.setOwnerName(businessArray.get(i).getOwnername());
                        selectedItemBean.setYwMaxNum(businessArray.get(i).getMax());
                        allSelectedItemBeans.add(selectedItemBean);
                    }

                }
            }
        }
        return allSelectedItemBeans;
    }

    /**
     * 保存叫号的数据到服务器上
     *
     * @param name  姓名
     * @param idNum 身份证号
     */
    private void saveSelectedYwToServer(String queueBusiness, String qhType, String name, String idNum) {
        if (!NetworkUtils.isConnected()) {
            ToastUtils.showShort(R.string.tip_connect_net_content);
            return;
        }
        mainYwActivity.showLoading();

        try {
            name = URLEncoder.encode(name, "utf-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }

        net(queueBusiness, qhType, name, idNum);
    }

    /**
     * 网络实际执者
     *
     * @param queueBusiness 选择业务数据
     * @param name          姓名
     * @param idNum         身份证号
     */
    private void net(final String queueBusiness, String qhType, String name, String idNum) {
        String deviceId = Tools.getDeviceId();
        EasyHttp.post(Contact.SAVE_YW_TO_SERVEr)
                .params("key", deviceId)
                .params("rsa", Tools.encodeRsa(deviceId))
                .params("xm", name)
                .params("sfzhm", idNum)
                .params("deptid", mainYwActivity.getResources().getString(R.string.deptId))
                .params("windowtype", qhType)
                .params("queueBusiness", queueBusiness)
                .params("ip", NetIpUtils.getLocalIPAddress().getHostAddress())
                .execute(new SimpleCallBack<String>() {
                    @Override
                    public void onError(ApiException e) {
                        LogUtils.i(e.getMessage() + e.getCode());
                        mainYwActivity.dismissLoading();
                        onErrorTip(StringUtils.getString(R.string.error_again) + e.getMessage());
                    }

                    @Override
                    public void onSuccess(String s) {
                        LogUtils.i(s);
                        mainYwActivity.dismissLoading();
                        handleJhSuccessResult(s, queueBusiness);
                    }
                });

    }

    /**
     * 处理实际的业务
     *
     * @param s             服务器返回的数据
     * @param queueBusiness 选择要办理的业务
     */
    private void handleJhSuccessResult(String s, String queueBusiness) {
        if (TextUtils.isEmpty(s)) {
            onErrorTip("空数据");
            return;
        }
        LogUtils.i(s);
        final JhResultBean jhResultBean = GsonProvider.getInstance().getGson().fromJson(s, JhResultBean.class);
        if (jhResultBean != null) {
            //打印小票
            if (jhResultBean.isSuccess()) {
                PrintManagerPjq.getInstance().print(jhResultBean, queueBusiness);
                ActivityUtils.startActivity(MainYwActivity.class);
                clear();
            } else {
                onErrorTip(jhResultBean.getMessage());
            }
        } else {
            onErrorTip("叫号数据返回为空");
        }
    }

    private void clear() {
        IGlabolCallback callback = CallbackManager.getInstance().getCallback(Contact.CLEAER_SELECTED_DATA);
        if (callback != null) {
            callback.executeCallback("");
        }
        mainYwAdapter.notifyDataSetChanged();
        SPUtils.getInstance().clear();
        CacheDiskStaticUtils.remove(Contact.SAVE_YW_SELECTED);
    }


    /**
     * 访问保存数据接口出错后的提示对话框，可以接着访问
     * 或者是关闭页面停止访问接口
     *
     * @param tip 提示信息
     */
    private void onErrorTip(String tip) {

        if (ActivityUtils.isActivityAlive(mainYwActivity)) {
            LemonHello.getErrorHello(tip, tip)
                    .addAction(new LemonHelloAction(StringUtils.getString(R.string.close), new LemonHelloActionDelegate() {
                        @Override
                        public void onClick(LemonHelloView lemonHelloView, LemonHelloInfo lemonHelloInfo, LemonHelloAction lemonHelloAction) {
                            lemonHelloView.hide();
                        }
                    })).show(mainYwActivity);
        }
    }

    /**
     * 清除所有选择的业务
     */
    public void clearAllYwTip() {
        //清除所有选中的业务
        clear();
    }

    /**
     * 关机tip
     */
    @Deprecated
    public void shutDown() {
        LemonHello.getInformationHello("关闭设备", "确认关闭吗?")
                .addAction(new LemonHelloAction(StringUtils.getString(R.string.cancel), new LemonHelloActionDelegate() {
                    @Override
                    public void onClick(LemonHelloView lemonHelloView, LemonHelloInfo lemonHelloInfo, LemonHelloAction lemonHelloAction) {
                        //隐藏提示
                        lemonHelloView.hide();
                    }
                }))
                .addAction(new LemonHelloAction(StringUtils.getString(R.string.sure), new LemonHelloActionDelegate() {
                    @Override
                    public void onClick(LemonHelloView lemonHelloView, LemonHelloInfo lemonHelloInfo, LemonHelloAction lemonHelloAction) {
                        lemonHelloView.hide();
                        //指定关闭设备的命令
                        excuteCmd(new String[]{"su", "-c", "reboot -pl"});
                    }
                }))
                .addAction(new LemonHelloAction(StringUtils.getString(R.string.reboot), new LemonHelloActionDelegate() {
                    @Override
                    public void onClick(LemonHelloView lemonHelloView, LemonHelloInfo lemonHelloInfo, LemonHelloAction lemonHelloAction) {
                        lemonHelloView.hide();
                        excuteCmd(new String[]{"su", "-c", "reboot"});
                    }
                })).show(ActivityUtils.getTopActivity());
    }

    /**
     * 通过获取root权限，执行关机命令
     */
    private void excuteCmd(String[] cmds) {
        try {
            Process process = Runtime.getRuntime().exec(cmds);
            int r = process.waitFor();
            java.lang.System.out.println("执行su命令返回值:" + r);
        } catch (IOException | InterruptedException e) {
            e.printStackTrace();
        }
    }

    /**
     * 设置关机按钮本机背景颜色
     *
     * @param tv 按钮控件
     */
    public void setShutDownColor(TextView tv) {
        ShadowDrawable.setShadowDrawable(tv, new int[]{
                        Color.parseColor("#C33764"), Color.parseColor("#1D2671")},
                SizeUtils.dp2px(6),
                Color.parseColor("#99C33764"),
                SizeUtils.dp2px(6), SizeUtils.dp2px(5), SizeUtils.dp2px(2));
    }

}
